from machine import Pin
from time import sleep_ms

class _74HC595:
    def __init__(self):
        self.__ds = Pin(18, Pin.OUT)
        self.__st = Pin(19, Pin.OUT)
        self.__sh = Pin(21, Pin.OUT)
        pass
    
    def write(self,v):
        self.__st.value(0)
        for i in range(8):
            #print((v>>(7-i))&1)
            self.__sh.value(0)
            self.__ds.value((v>>(7-i))&1)
            self.__sh.value(1)
            sleep_ms(1)
        self.__sh.value(0)
        self.__st.value(1)
        sleep_ms(1)
        self.__st.value(0)
        print('finish')
        pass

micro=_74HC595()
micro.write(0b00000110)
sleep_ms(500)
micro.write(0b11111101)
print('123123')